<?php
class Warehouse_Service_House
{

	public static function getByCondition($condition,$type='*',$order, $pageSize=0, $page=1)
	{ 
		$obj=new Warehouse_Model_House();
		$rows= $obj->getByCondition( $condition,$type,$order, $pageSize,$page);	
		return ($rows);
	}

	public static function getByfield($field,$value)
	{ 
		$obj=new Warehouse_Model_House();
		$rows= $obj->getByfield($field,$value);
		if(!empty($rows)){
			$rows=$rows->toArray();
		}
		return $rows;
	}
	
	
	public static function getById($t_id)
	{ 
		$obj=new Warehouse_Model_House();
		$rows=$obj->getById($t_id);
		if(!empty($rows)){
			$rows=$rows->toArray();
		}
		return $rows;
	}


	public static function create($row)
	{ 
		$obj=new Warehouse_Model_House();
		return $obj->create($row);
	}

	public static function update($row,$t_id)
	{ 
		$obj=new Warehouse_Model_House();
		return $obj->update($row,$t_id);
	}	
	/**
	*根据分区CODE，级联修改wh_status
	*@param string $wa_code, 
	*/
	public static function updateStatus($wa_code,$status)
	{ 
		$updateRow=array(
			'wh_status'=>$status
		);
		$obj=new Warehouse_Model_House();
		$obj->updateByWaCode($updateRow,$wa_code);
	}		
	
	public static function delete($id)
	{ 
		$obj=new Warehouse_Model_House();
		return $obj->delete($id);
	}		
	
	public static function getByWaCode($wa_code){
		$obj=new Warehouse_Model_House();
		return $obj->getByWaCode($wa_code);
	}

    public static function validator($val) {
        $error = array();
        $validateArr = array();
        $validateArr[] = array('name' => '房间号', 'value' => $val['wh_code'], 'regex' => array('require', 'length[0,255]', ));
        $error = Common_Service_Validator::formValidator($validateArr);
        return $error;
    }
	
}